Debugging I2C GPIO
Perform the following steps to debug I2C:
-
Execute the following command to scan the bus:
i2cdetect -l
Result: -
Execute the following command to detect the device:
i2cdetect -y -r 0
Tip:0 is the I2C bus number.
Result:In this figure, the detected devices are0x29
,0x48
,0x5c
,0x68
, and0x70
. -
Execute the following command to read register content:
i2cget -f -y 0 0x5c 0x0f
Tip:-
0
: I2C bus number -
0x5c
: I2C device address -
0x0f
: Memory address
Result:The register content is 0xb1 in this output.
-
-
Execute the following command to write register data:
i2cset -y 0 0x5c 0x11 0x10
Tip:-
0
: I2C bus number. -
0x5c
: I2C device address. -
0x11
: Memory address. -
0x10
: The content to be written in the register.
-
-
Execute the following to read all register values:
i2cdump -y 0 0x5c
Tip:-
0
: I2C bus number -
0x5c
: I2C device address
Result: -